using Volo.Abp.MultiTenancy;

using WL.Think.Abp.Localization;
using WL.Think.Abp.OpenIddict.Permission;
using WL.Think.Abp.Permission;

namespace WL.Think.Abp.OpenIddict.ApplicationContracts.Permission
{
    public class OpenIddictPermissionDefinitionProvider : GroupPermissionDefinitionProvider<ThinkResource>
    {
        protected override string Name => OpenIddictPermissions.GroupName;

        protected override string DisplayName => "OpenIddictManagement";

        protected override void DefinePermission()
        {
            var applicationPermission = AddPermission(OpenIddictPermissions.Applications.Default, "Applications", MultiTenancySides.Host);
            AddChild(applicationPermission, OpenIddictPermissions.Applications.Create, ThinkResourceNames.Create, MultiTenancySides.Host);
            AddChild(applicationPermission, OpenIddictPermissions.Applications.Update, ThinkResourceNames.Update, MultiTenancySides.Host);
            AddChild(applicationPermission, OpenIddictPermissions.Applications.Delete, ThinkResourceNames.Delete, MultiTenancySides.Host);

            var scopePermission = AddPermission(OpenIddictPermissions.Scopes.Default, "Scopes", MultiTenancySides.Host);
            AddChild(scopePermission, OpenIddictPermissions.Scopes.Create, ThinkResourceNames.Create, MultiTenancySides.Host);
            AddChild(scopePermission, OpenIddictPermissions.Scopes.Update, ThinkResourceNames.Update, MultiTenancySides.Host);
            AddChild(scopePermission, OpenIddictPermissions.Scopes.Delete, ThinkResourceNames.Delete, MultiTenancySides.Host);
        }
    }
}
